﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sylvain.Manager;
using System.Web.Security;

public partial class Admin_EditHome : System.Web.UI.Page
{
    ISylvainManager objManger = new SylvainManager();
    static int PageId;
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Buffer = true;
        Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
        Response.Expires = 0;
        Response.CacheControl = "no-cache";
        if (!Page.User.Identity.IsAuthenticated)
            Response.Redirect("~/Admin/AdminLogin.aspx", false);

        if (!IsPostBack)
        {


            PageId = objManger.GetPageId("home");
            FckEditor1.Value= objManger.GetPageContent(PageId);
        }
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        ISylvainManager objManger = new SylvainManager();
        //Get current user
        MembershipUser userInfo = Membership.GetUser();
        if (userInfo != null)
        {
            objManger.InsertPageContent(PageId, FckEditor1.Value, userInfo.UserName);
        }
        else 
        {
            Response.Redirect("~/Admin/AdminLogin.aspx", false);
        }
       
        lblError.Text = "Content has been updated sucessfully.";
    }
}